 % creates a class named synapse, placed in file 'synapse.m'
classdef synapse
    properties
        weight;                 % synapse weight
        definedRechargingTime;  % property of the synapse - defined recharging time
        remainingTime;          % variable that contains remaining time to be active
        active;                 % 1 - active, 0 - inactive
        inputNeuronId;          % pair (inputNeuronId, inputNeuronLayer) identifies the input neuron (neuron from which signal is transmitted through the synapse)
        inputNeuronLayer;       %
        outputNeuronId;         % pair (outputNeuronId, outputNeuronLayer) identifies the output neuron (neuron to which signal is transmitted through the synapse)
        outputNeuronLayer;      %
        epochsWithoutUse;       % For leraning purpose:
        belongsToMemory;        % 1 - Yes, 0 - No
        memoryThreshold;        %
        deathThreshold;         %
        
    end
    methods
        % Basic function
        % constructor
        function obj = synapse(weight, definedRechargingTime, inputNeuronId, inputNeuronLayer, outputNeuronId, outputNeuronLayer, belongsToMemory, memoryThreshold, deathThreshold, epochsWithoutUse)
            obj.weight = weight;
            obj.definedRechargingTime = definedRechargingTime;
            obj.remainingTime = 0;      %when we create synapse it by default is active
            obj.active = 1;
            obj.inputNeuronId = inputNeuronId;
            obj.inputNeuronLayer = inputNeuronLayer;
            obj.outputNeuronId = outputNeuronId;
            obj.outputNeuronLayer = outputNeuronLayer;
            obj.epochsWithoutUse = 0;
            obj.belongsToMemory = belongsToMemory;
            obj.memoryThreshold = memoryThreshold;
            obj.deathThreshold =  deathThreshold;
            obj.epochsWithoutUse = epochsWithoutUse;
        end
        % display synapse
        function disp(obj)
            s = sprintf('%d(%d) -> %d(%d) (weigth: %.2f recharging time: %d active: %d in memory: %d memory threshold: %d death threshold: %d)', ...
                obj.inputNeuronId, obj.inputNeuronLayer, ...
                obj.outputNeuronId, obj.outputNeuronLayer, ...
                obj.weight, obj.remainingTime, obj.active, obj.belongsToMemory, obj.memoryThreshold, obj.deathThreshold);
            disp(s);
        end
        
    end
end